package com.huadao.cart_ccs.greendao.PropertyConverter;

import com.huadao.cart_ccs.data.bo.ExperimentStage;

import org.greenrobot.greendao.converter.PropertyConverter;

public class ExperimentStageConvert implements PropertyConverter<ExperimentStage, String> {
    @Override
    public ExperimentStage convertToEntityProperty(String databaseValue) {
        ExperimentStage experimentStage=new ExperimentStage();
        String[] d=databaseValue.split(" ");
        if(d.length==2) {
            experimentStage.setDay(Integer.parseInt(d[0]));
            experimentStage.setStage(d[1]);
        }
        return experimentStage;
    }

    @Override
    public String convertToDatabaseValue(ExperimentStage entityProperty) {
        StringBuilder stringBuilder=new StringBuilder();
        stringBuilder.append(entityProperty.getDay());
        stringBuilder.append(" ");
        stringBuilder.append(entityProperty.getStage());
        return stringBuilder.toString();
    }
}
